﻿using System;

namespace Common
{
    public class ClassContact
    {
        public ClassContact() { }

        /// <summary>
        /// 联系人所属大队GUID
        /// </summary>
        public Guid Brigade
        {
            set;
            get;
        }

        /// <summary>
        /// 联系人姓名
        /// </summary>
        public string Name
        {
            set;
            get;
        }

        /// <summary>
        /// 联系人电话
        /// </summary>
        public string Phone
        {
            set;
            get;
        }

        public string Coding2String()
        {
            string b = null;
            b += this.Brigade.ToString() + "♠";
            b += this.Name + "♠";
            b += this.Phone;
            return b;
        }

        public void DecodingFromString(string message)
        {
            string buf = null;
            if(message[message.Length - 1].Equals('♠'))
            {
                buf = message.Substring(0, message.Length - 1);
            }
            else
            {
                buf = message;
            }
            string[] str = buf.Split('♠');
            this.Brigade = new Guid(str[0]);
            this.Name = str[1];
            this.Phone = str[2];
        }
    }
}
